package com.guanyong.admin.controllers.api;

import com.guanyong.model.UserBaseModel;
import com.guanyong.model.VideoBuyLogModel;
import com.guanyong.services.VideoBuyLogServices;
import com.guanyong.utils.Comm.DateExt;
import com.guanyong.utils.Comm.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * Created by mxk on 2017/6/23.
 */
@RestController
@RequestMapping("/api/account/")
public class AccountApi {

    @Autowired
    VideoBuyLogServices videoBuyLogServices;

    @RequestMapping(value = "getBuyLoglist", method = RequestMethod.GET)
    ResultObject<HashMap<String,Object>> getVideoBuyLog(HttpServletRequest request,
                                                        @RequestParam Integer fBilltype ,
                                                        @RequestParam Integer fApptype,
                                                        @RequestParam Integer fClasstype,
                                                        @RequestParam Integer fState,
                                                        @RequestParam Integer isoff,
                                                        @RequestParam String timeSection,
                                                        @RequestParam int pno,
                                                        @RequestParam int pagesize,
                                                        @RequestParam int allcount) {
        ResultObject<HashMap<String,Object>> result = new ResultObject<HashMap<String,Object>>();
        VideoBuyLogModel videoBuyLogModel = new VideoBuyLogModel();
        videoBuyLogModel.setfState(fState);
        videoBuyLogModel.setfBilltype(fBilltype);
        videoBuyLogModel.setfClasstype(fClasstype);
        videoBuyLogModel.setfApptype(fApptype);
        String btime =null;
        String etime =null;
        if(timeSection!=null){
            String[]temp = timeSection.split("-");
            if (temp.length==2){
                btime =temp[0].trim();
                etime =temp[1].trim();
                btime = DateExt.DateToStr(DateExt.startStrToDate(btime));
                etime = DateExt.DateToStr(DateExt.startStrToDate(etime));
                System.out.println(btime+"----"+etime);
            }
        }
        HashMap<String,Object> hashMap=videoBuyLogServices.GetVideoBuyLogList(videoBuyLogModel,isoff,btime,etime,pno,pagesize,allcount);
        result.setResult(hashMap);
        return result;
    }
}
